<template>
  <div class="page-style">
    <tb-bt :tb-status="tb_status" :select-arr="selectArr" @statusChange="statusChange" @reloadFun="reloadFun" @search="searchFun" />
    <tb-table :table-data="list" @reloadFun="reloadFun" @selectArr="selectArrFun" />
    <pagination :total="total" @pagination="pagination" />
  </div>
</template>

<script>
import pagination from '@/components/Pagination'
import tbTable from './components/taobao/tb-tab'
import tbBt from './components/taobao/tb-btn'
import { getTbListApi } from '@/api/agent'
export default {
  components: {
    pagination,
    tbTable,
    tbBt
  },
  data() {
    return {
      brand_id: '',
      tb_status: '0',
      p: 1,
      num: 10,
      total: 0,
      code_num: '',
      list: [],
      selectArr: []
    }
  },
  created() {
    this.getTbList()
  },
  methods: {
    searchFun(val) {
      console.log(val)
      this.code_num = val.code_num
      this.getTbList()
    },
    getTbList() {
      const data = {
        brand_id: this.brand_id,
        tb_status: this.tb_status,
        p: this.p,
        num: this.num,
        code_num: this.code_num
      }
      getTbListApi(data).then(res => {
        console.log(res)
        this.list = res.list
        this.total = Number(res.count)
      })
    },
    pagination(val) {
      this.p = val.page
      this.num = val.limit
      this.getTbList()
    },
    statusChange(val) {
      this.tb_status = val
      this.getTbList()
    },
    reloadFun() {
      this.getTbList()
    },
    selectArrFun(val) {
      console.log(val)
      this.selectArr = val
    }
  }
}
</script>

<style lang="sass" scoped>

</style>
